﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class BaseData_ProductStyleDetail : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSMThemes();
    }
    private string tablename = "FJSX1 A left join sxmx B on A.sxdm=B.SXID and B.TableName='FJSX1' left join SHUXING C on B.MXID=C.SX_ID";
    private string fieldname = "SXDM,SXMC,XTMR,BYZD1,BYZD2,BYZD3,BYZD4,SX_MC";
    protected void Page_Load(object sender, EventArgs e)
    {
        Check.CheckPermission("200200109");
        if (!IsPostBack)
        {
            AspNetPager1.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["RowCountPerPage"].ToString());
            SearchControl1.InitParam(tablename,fieldname,"SXDM", "SXMC", "FJSX1ListControl1", "rptFJSX1", "AspNetPager1");
            Bind();
            InitDanymic();
        }
    }
    private void Bind()
    {
        int pageCount, rowCount;
        List<Model.FJSX1> styleDetail = new BLL.FJSX1().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex,tablename,fieldname,"SXDM", false, "", out pageCount, out rowCount);
        FJSX1ListControl1.Bind(styleDetail);
        AspNetPager1.RecordCount = rowCount;
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        int pageCount, rowCount;
        if (SearchControl1.IsSearchResult)
        {
            Repeater rpt = (Repeater)FJSX1ListControl1.FindControl("rptFJSX1");
            if (rpt != null)
            {
                string strSql;
                SearchControl1.BindParentPageControl(rpt, AspNetPager1, SearchControl1.DataTableName,SearchControl1.FieldName,SearchControl1.PrimaryKeyColumnName, SearchControl1.StrCondition, AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, out pageCount, out rowCount, out strSql);
            }
        }
        else
        {
            List<Model.FJSX1> colors = new BLL.FJSX1().GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, tablename, fieldname, "SXDM", false, "", out pageCount, out rowCount);
            FJSX1ListControl1.Bind(colors);
        }
    }
    private void InitDanymic()
    {
        string flag = ConfigurationManager.AppSettings["DynamicProperty"].ToString();
        if (flag == "1")
        {
            UpdatePanel2.Visible = true;
            List<Model.SHUXING> l = new BLL.SHUXING().GetList("FJSX1");
            SXMXControl1.Bind(l);
        }
        else
        {
            UpdatePanel2.Visible = false;
        }
    }
    public void AddProperty()
    {
        List<string> s = FJSX1ListControl1.Selected;
        if (s.Count < 1)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('有选择记录');", true);
        }
        else
        {
            string sxid = SXMXControl1.SXID;
            string sxzcode = "";
            for (int i = 0; i < s.Count; i++)
            {
                sxzcode = sxzcode + s[i]+",";
            }
            string table = "FJSX1";
            bool f = new BLL.SXMX().Add(sxid, table, sxzcode);
            if (f)
            {
                Bind();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('提交失败！');", true);
            }
        }
    }
}
